home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_10.lha
/
7_10
/
p_stime.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
45 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <process.h>
include <debug.h> /* DELETE */
/ Set the pseudo-clock.
oid process::stime(unsigned long t)
if (debug) /*DELETE*/ cerr << "process" << this << "::stime(" << t << ")\n";
t_curtime = t;
// skip past the beginning processes
for (process **pp = &t_runprocesses;
*pp && ((*pp)->t_desiredtime == 0);
pp = &(*pp)->t_next)
if (debug) /*DELETE*/ cerr << "\t" << (*pp) << "-> desiredtime = " << (*pp)->t_desiredtime << ", skipped\n"
;
// move all passed-by processes to a safe place
process *saveprocs = 0;
while (*pp && ((*pp)->t_desiredtime <= t))
{
if (debug) /*DELETE*/ cerr << "\t" << (*pp) << "-> desiredtime = " << (*pp)->t_desiredtime << ", saved\n";
process *sv = *pp;
process *svn = sv->t_next;
*pp = svn;
sv->t_next = saveprocs;
saveprocs = sv;
}
// move the processes back onto the run queue
while (saveprocs)
{
if (debug) /*DELETE*/ cerr << "\t" << saveprocs << ", shuffled\n";
process *sv = saveprocs;
saveprocs = sv->t_next;
sv->t_desiredtime = 0;
sv->t_next = t_runprocesses;
t_runprocesses = sv;
shufflerunlist();
}
if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::stime(" << t << ")\n";